//
//  MatchViewController.m
//  NBAApp
//
//  Created by 刘意明 on 16/11/30.
//  Copyright © 2016年 Manito. All rights reserved.
//

#import "MatchViewController.h"
#import "MyViewController.h"//我的
#import "SGSegmentedControl.h"
@interface MatchViewController ()<UIScrollViewDelegate, SGSegmentedControlDelegate>
{
    SGSegmentedControl *seg;
}
@property (nonatomic, strong) SGSegmentedControl *SG;
@property (nonatomic, strong) UIScrollView *mainScrollView;

@end

@implementation MatchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //导航条上的按钮
    self.view.backgroundColor=[UIColor whiteColor];
    self.navigationItem.title=@"比赛";
    
    UIBarButtonItem *right =[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"人物.png"] style:UIBarButtonItemStylePlain target:self action:@selector(ClickMy:)];
    self.navigationItem.rightBarButtonItem=right;
    
    UIBarButtonItem *left =[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"篮球.png"] style:UIBarButtonItemStylePlain target:self action:@selector(Click:)];
    self.navigationItem.leftBarButtonItem=left;
    //分段控制器
    [self SegmentedControl];
}


-(void)SegmentedControl
{
//    //先生成存放标题的数据
//    NSArray *array = [NSArray arrayWithObjects:@"赛程",@"我的主队", nil];
//    //初始化UISegmentedControl
//    UISegmentedControl *segment = [[UISegmentedControl alloc]initWithItems:array];
//    //设置frame
//    segment.frame = CGRectMake(0, 64, self.view.frame.size.width, 50);
//    //添加到视图
//    [self.view addSubview:segment];
//    //根据内容定分段宽度
//  //  segment.apportionsSegmentWidthsByContent = YES;
//    //开始时默认选中下标(第一个下标默认是0)
//    segment.selectedSegmentIndex = 0;
//    //控件渲染色(也就是外观字体颜色)
//   // segment.tintColor = [UIColor blueColor];
//    //按下是否会自动释放：
//    //segment.momentary = YES;
//    //设置样式
//    segment.segmentedControlStyle=UISegmentedControlStyleBar;
//    
//    [segment addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];
    
   }
- (void)SGSegmentedControl:(SGSegmentedControl *)segmentedControl didSelectBtnAtIndex:(NSInteger)index
{
    NSArray *aa=[NSArray arrayWithObjects:@"aa",@"bb", nil];
    seg =[[SGSegmentedControl alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 50) delegate:self segmentedControlType:SGSegmentedControlTypeScroll titleArr:aa];
    [self.view addSubview:seg];

}
//点击不同分段就会有不同的事件进行相应
-(void)change:(UISegmentedControl *)sender
{
    NSLog(@"测试");
    if (sender.selectedSegmentIndex == 0) {
        NSLog(@"1");
    }else if (sender.selectedSegmentIndex == 1){
        NSLog(@"2");
   }
}
//点击右上角跳转到我的
- (void)ClickMy:(UIBarButtonItem *)btn {
    MyViewController *mm =[[MyViewController alloc] init];
    mm.hidesBottomBarWhenPushed = YES;//隐藏tabbar
    [self.navigationController pushViewController:mm animated:YES];
    mm.hidesBottomBarWhenPushed = NO;
}
//点击右上角跳转到篮球
- (void)Click:(UIBarButtonItem *)btn {
    
}
//视图将要出现
-(void)viewWillAppear:(BOOL)animated
{
    
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    self.navigationItem.hidesBackButton = YES;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
